﻿<form id="auth-client-form" lay-filter="auth-client-form" class="layui-form model-form">
    <input name="id" type="hidden"/>
    <input name="createTime" type="hidden"/>
    <input name="state" type="hidden" value="1"/>
    <div class="layui-form-item">
        <label class="layui-form-label">账号</label>
        <div class="layui-input-block">
            <input name="clientId" placeholder="请输入账号" type="text" class="layui-input" maxlength="20"
                   lay-verify="required" required/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">资源范围</label>
        <div class="layui-input-block">
            <input name="resourceIds" placeholder="请输入用户名" type="text" class="layui-input" maxlength="20"
                   lay-verify="required" required/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">权限范围</label>
        <div class="layui-input-block">
            <input name="scope" placeholder="请输入权限范围" type="text" class="layui-input" lay-verify="required"
                   required/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">授权类型</label>
        <div class="layui-input-block">
            <input name="authorizedGrantTypes" placeholder="请输入授权类型" type="text" class="layui-input"  lay-verify="required"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">token过期时间</label>
        <div class="layui-input-block">
            <input name="accessTokenValidity" placeholder="请输入token过期时间" type="text" class="layui-input"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">refreshToken过期时间</label>
        <div class="layui-input-block">
            <input name="refreshTokenValidity" placeholder="请输入refreshToken过期时间" type="text" class="layui-input"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">额外信息</label>
        <div class="layui-input-block">
            <input name="additionalInformation" placeholder="请输入额外信息" type="text" class="layui-input"/>
        </div>
    </div>
    <div  style="display: none">
        <button class="layui-btn" lay-filter="auth-client-submit" id = "auth-client-submit" lay-submit>保存</button>
    </div>
</form>

<script>
    layui.use(['layer', 'form','admin','util'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var admin = layui.admin;
        var util = layui.util;
        var url = 'system/user/add';  // 实际项目这里是添加用户的url
        // 回显user数据
        var clientDetails = admin.getTempData('auth-client-form-obj');
        if (clientDetails) {
            $('#auth-client-form input[name="clientId"]').attr('readonly', 'readonly');
            url = 'auth/client/update';  // 实际项目这里是修改用户的url
            form.val('auth-client-form', clientDetails);
            $('#auth-client-form input[name="createTime"]').val(util.toDateString(clientDetails.createTime));
        }

        // 表单提交事件
        form.on('submit(auth-client-submit)', function (data) {
            admin.req(url, data.field, function (data) {
                layer.msg("保存成功", {icon: 1});
                admin.putTempData('auth-client-formOk', true);  // 操作成功刷新表格
                layer.close(layer.curr_idex)
            },"post");
            return false;
        });
    });
</script>

</body>
</html>